package edu.hawaii.duedates;

import java.util.Comparator;

/**
 * An object to hold the specifics on each borrowed item with a
 * respective due date. Can be used with any LibraryVault system.
 * 
 * @author Tyler Wolff and Scheller Sanchez
 */

public class ItemDue {
  
  String itemLib;
  String itemName;
  String itemType;
  String itemDueDate;
  
  /**
   * ItemDue constructor.
   * 
   * @param itemLib The Name of the Library.
   * @param itemName The Name of the borrowed item.
   * @param itemType The type of item (ie: book, video, etc).
   * @param itemDueDate The due date of borrowed item.
   */

  public ItemDue (String itemLib, String itemName, String itemType, String itemDueDate) {
    
    this.itemLib = itemLib;
    this.itemName = itemName;
    this.itemType = itemType;
    this.itemDueDate = itemDueDate;
    
  } //end constructor
 
  /**
   * Returns a Comparator object that returns a comparator that allows a collection of
   * ItemDue Objects to be sorted based on Library Location.
   * 
   * @return A comparator that compares ItemDue objects based on Library location
   */
  public static final Comparator<ItemDue> libraryComparator = new Comparator<ItemDue>() {
    public int compare(ItemDue itemDue1, ItemDue itemDue2) {
      return itemDue1.itemLib.compareTo(itemDue2.itemLib);
    }
  };
  
  /**
   * Returns a Comparator object that returns a comparator that allows a collection of
   * ItemDue Objects to be sorted based on duedate.
   * 
   * @return A comparator that compares ItemDue objects based on duedate
   */
  public static final Comparator<ItemDue> dueDateComparator = new Comparator<ItemDue>() {
    public int compare(ItemDue itemDue1, ItemDue itemDue2) {
      return itemDue1.itemDueDate.compareTo(itemDue2.itemDueDate);
    }
  };
  
} //end ItemDue class
